Skip to content

Conversation

@vicb
Copy link
Contributor

@vicb vicb commented Jan 22, 2025

Summary

Clarify how wrangler --env affects loading .env and .dev.vars

Related to cloudflare/workers-sdk#7859

Documentation checklist

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Jan 22, 2025

Deploying cloudflare-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 9298939
Status: ✅  Deploy successful!
Preview URL: https://9b273a98.cloudflare-docs-7ou.pages.dev
Branch Preview URL: https://envarg.cloudflare-docs-7ou.pages.dev

View logs

@github-actions
Copy link
Contributor

Copy link
Contributor

@petebacondarwin petebacondarwin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we explicitly call out that we do not combine the vars from .env.<env-name> with those in .env?

@vicb
Copy link
Contributor Author

vicb commented Jan 22, 2025

Should we explicitly call out that we do not combine the vars from .env.<env-name> with those in .env?

I think it would be a great idea, can you add this as a suggestion - your english is better than mine :)
Thanks

@vicb
Copy link
Contributor Author

vicb commented Jan 24, 2025

@ToriLindsay can you please take a look when you have time? 🙏

@vicb vicb enabled auto-merge (squash) January 28, 2025 13:52

:::note

You can set system environment variables per environment by creating additional files with the naming convention `.env.<environment-name>`. When you set the environment using `wrangler <command> --env <environment-name>`, such an environment specific file will be loaded instead of the `.env` file - they are not merged.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
You can set system environment variables per environment by creating additional files with the naming convention `.env.<environment-name>`. When you set the environment using `wrangler <command> --env <environment-name>`, such an environment specific file will be loaded instead of the `.env` file - they are not merged.
To set different system environment variables for each environment, create files named `.env.<environment-name>`. When you use `wrangler <command> --env <environment-name>`, the corresponding environment-specific file will be loaded instead of the `.env` file, so the two files are not merged.

```

You can set secrets per environment by creating additional files with the naming convention `.dev.vars.<environment-name>`. Like other environment variables, secrets are [non-inheritable](/workers/wrangler/configuration/#non-inheritable-keys) and must be defined per environment.
You can set secrets per environment by creating additional files with the naming convention `.dev.vars.<environment-name>`. When you set the environment using `wrangler <command> --env <environment-name>`, such an environment specific file will be loaded instead of the `.dev.vars` file - they are not merged.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
You can set secrets per environment by creating additional files with the naming convention `.dev.vars.<environment-name>`. When you set the environment using `wrangler <command> --env <environment-name>`, such an environment specific file will be loaded instead of the `.dev.vars` file - they are not merged.
To set different secrets for each environment, create files named `.dev.vars.<environment-name>`. When you use `wrangler <command> --env <environment-name>`, the corresponding environment-specific file will be loaded instead of the `.dev.vars` file, so the two files are not merged.

@vicb vicb merged commit e76d68d into production Jan 28, 2025
12 checks passed
@vicb vicb deleted the envarg branch January 28, 2025 14:28
vicb added a commit that referenced this pull request Jan 28, 2025
vicb added a commit that referenced this pull request Jan 28, 2025
deadlypants1973 pushed a commit that referenced this pull request Jan 29, 2025
deadlypants1973 pushed a commit that referenced this pull request Jan 29, 2025
kodster28 pushed a commit that referenced this pull request Jan 30, 2025
kodster28 pushed a commit that referenced this pull request Jan 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

product:workers Related to Workers product size/xs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants